using System;

namespace Ro.Norc.ServiceStackClient
{
	/// <summary>
	/// The standard interface that a service encoder must implement
	/// </summary>
	public interface ServiceEncoderInterface
	{
		/// <summary>
		/// Encodes a given object to a string representation
		/// </summary>
		/// <param name="obj">
		/// The object to encoder
		/// </param>
		/// <returns>
		/// The object representation
		/// </returns>
		string Encode(object obj);
		
		/// <summary>
		/// Decodes a given string representation to an object of the given type parameter T
		/// </summary>
		/// <param name="repr">
		/// A string representation to be decoded
		/// </param>
		/// <returns>
		/// An object of type T
		/// </returns>
		object Decode(string repr, Type t);
		
		/// <summary>
		/// Returns true if the encoder can decode string representations of the given content type. This method is called before attempting a decode operation.
		/// </summary>
		/// <param name="contentType">
		/// The content type to be validated
		/// </param>
		/// <returns>
		/// True if the encoder supports the given content type, false otherwise
		/// </returns>
		bool IsContentTypeValid(string contentType);
		
		/// <summary>
		/// Gets the content type of the string representation produced by ServiceEncoderInterface.Encode()
		/// </summary>
		string ContentType { get; }
		
		/// <summary>
		/// Gets the string that is automatically appended to the URL by the Service class, should this behaviour be enabled
		/// </summary>
		string EndpointPart { get; }
	}
}